﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/static/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<base href="<%=basePath%>">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>实体维护</title>
		<meta name="description" content="" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
		<link rel="stylesheet" href="static/ace/css/bootstrap.css" />
		<link rel="stylesheet" href="static/ace/css/font-awesome.css" />
		<!-- text fonts -->
		<link rel="stylesheet" href="static/ace/css/ace-fonts.css" />
		<!-- ace styles -->
		<link rel="stylesheet" href="static/ace/css/ace.css" class="ace-main-stylesheet" id="main-ace-style" />
		<link rel="stylesheet" type="text/css" href="plugins/websocketInstantMsg/ext4/resources/css/ext-all.css">
		<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/ext-all-debug.js"></script>

	</head>
		 
<body class="no-skin">
	<!-- /section:basics/navbar.layout -->
	<div class="main-container" id="main-container">
		<div id="output"></div>
	</div>
</body>

	<script type="text/javascript">

		Ext.onReady(function () {
			var store = Ext.create('Ext.data.Store', {
				fields: ["cataId", "cataNo", "cataRemark", "cataTitle", "cataObjectName", "cataeditstatusName",
					"cataPublishName", "cataEndDate", "holyUpdateTime", "catapushtime"],
				pageSize: 20,  //页容量5条数据
				//是否在服务端排序 （true的话，在客户端就不能排序）
				remoteSort: false,
				remoteFilter: true,
				proxy: {
					type: 'ajax',
					url: '../test/list',
					reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
						type: 'json', //返回数据类型为json格式
						root: 'list',  //数据
						totalProperty: 'total' //数据总条数
					}
				},
				sorters: [{
					//排序字段。
					property: 'ordeId',
					//排序类型，默认为 ASC
					direction: 'desc'
				}],
				autoLoad: true  //即时加载数据
			});

			var grid = Ext.create('Ext.grid.Panel', {
				renderTo: "output",
				store: store,
				height: 400,
				width: 800,
				stripeRows:true,
				columnLines: true,
//            selModel: {selType: 'checkboxmodel'},   //选择框
//            selType: 'checkboxmodel',
				selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"single", allowDeselect: true, showHeaderCheckbox:false}),
				columns: [
					{text: '型录2', dataIndex: 'cataId', align: 'left', maxWidth: 100},
					{text: '型录编号', dataIndex: 'cataNo', maxWidth: 100 ,locked:true,renderer: convert},
					{text: '助记标题', dataIndex: 'cataTitle', align: 'left', minWidth: 80},
					{text: '应用对象', dataIndex: 'cataObjectName', maxWidth: 80, align: 'left'},
					{text: '发布状态', dataIndex: 'cataPublishName', maxWidth: 80},
					{text: '活动截止日期', dataIndex: 'cataEndDate', xtype: 'datecolumn', dateFormat: 'Y-m-d H:i:s'},
					{text: '更新时间', dataIndex: 'holyUpdateTime', xtype: 'datecolumn', dateFormat: 'Y-m-d H:i:s'},
					{text: '发布时间', dataIndex: 'catapushtime', xtype: 'datecolumn', dateFormat: 'Y-m-d H:i:s'}
				],
				bbar: [{
					xtype: 'pagingtoolbar',
					store: store,
					displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
					emptyMsg: "没有数据",
					beforePageText: "当前页",
					afterPageText: "共{0}页",
					displayInfo: true
				}],
				listeners: {
					'itemclick': function (view, record, item, index, e) {
//                    Ext.MessageBox.alert("标题", record.data.cataId);
					}
				},
				tbar: [
					{text: '新增', icon:'../plugins/ext4/shared/icons/fam/add.png', handler: showAlert}, "-",
					{text: '编辑', iconCls: 'a_edit2', handler: showAlert}, "-",
					{text: '停用/启用', iconCls: 'a_lock'}, "-",
					{text: '发布', iconCls: 'a_upload', handler: showAlert}, "-",
					{text: '组织型录', iconCls: 'a_edit', handler: showAlert}, "-",
					{text: '管理商品', iconCls: 'a_edit', handler: showAlert}, "-",
					"->", {iconCls: "a_search", text: "搜索", handler: showAlert}],
			});

			function showAlert() {
//            var selectedData = grid.getSelectionModel().getSelection()[0].data;
				store.load({ params: { abcd: 'test',test:666} });
			}

			function convert(val) {
				return Ext.util.Format.date(new Date(val), 'Y-m-d');
			}

		});


	</script>

</html>